#pragma once
#include "dataStruct.h"
#include "DataManager.h"
#include <map>

typedef map<CString,INT64>  deskMap;

class CSeverData
{
public:
	CSeverData(void);
	CSeverData(CDataManager* pData);
	~CSeverData();
	void Initialize();
	void Lock(){EnterCriticalSection(&m_CriticalSection); }
	void UnLock(){LeaveCriticalSection(&m_CriticalSection);}

	int getAreaCount(){return (int)m_vAreaInfo.size();}
	const areaInfo& getAreaInfo(int nIndex){return m_vAreaInfo[nIndex];}
	void addNewDesktop(const desktopInfo& desktop,int areaIndex);
	void delNewDesktop(const wchar_t* desktop,int areaIndex);
	void addArea(const wchar_t* areaName);
	void delArea(const wchar_t* areaName);
	bool checkPasswdIsRight(const userAccount& user,int& right);
	void getEmployeeShort(employeeShortInfo& shortInfo,const CString& strId);
	void setBookStateReady(const CTime& startTime,const CTime& endTime);
	void setValidBookState(const CTime& endTime);
	void GetBookData(vector<bookManagerData>& pData,const CTime& nowTime,const wchar_t* deskName,const wchar_t* areaName);
	void addBookData(const newBookData& pData);
	void delBookData(const hjcTime& setTime,const hjcDate& setDate);

	void addOrder(const INT64& serial,const Order& vOrder);
	void updateOrder(const INT64& serial,const Order& order);
	void getOrder(const INT64& serial, Order& order);
	foodParam getFoodParamByID(const wchar_t* id);
	foodParam getFoodParamByAbbr(const wchar_t* abbr);

	void getDiscount(vector<discount>& vDiscount,const wchar_t* discountName);

	INT64	getSerial(const wchar_t* areaName,const wchar_t* deskName);
	void checkOut(const wchar_t* areaName,const wchar_t* deskName);
	void setState(const setDeskState* state);
	vector<areaInfo> m_vAreaInfo;
private:
	//vector< vector<INT64> > m_vSerial;
	map<CString,deskMap> m_areaMap;
	vector<userAccount> m_vUserInfo;
	CDataManager* m_pData;
	CRITICAL_SECTION m_CriticalSection;
};
